home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / apps / 621 / label.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-12  |  3.0 KB  |  125 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <tos.h>
  4.  
  5. typedef struct 
  6.                     { char firstchar[1];
  7.                       char start[5];
  8.                       char renew[5];
  9.                       char title[26];
  10.                       char name[28];
  11.                       char address[28];
  12.                       char citystate[21];
  13.                       char zip[6];
  14.                       char phone[8];
  15.                       char area[4];
  16.                       char group[2];
  17.                       char lastchar[1];
  18.                     } 
  19.                     RECORD ;
  20.  
  21. #define RECORDLEN sizeof(RECORD)
  22.  
  23. static RECORD record, emptyrecord;
  24.  
  25. static int currentdate;
  26.  
  27.  
  28. void seteoss(char* cp);
  29. void printrecord(RECORD record);
  30. void whatdate(void);
  31. int main(void);
  32.  
  33.  
  34. void seteoss(char* cp)
  35.  {
  36.   cp +=  5; *cp = '\0';
  37.   cp +=  5; *cp = '\0';
  38.   cp += 26; *cp = '\0';
  39.   cp += 28; *cp = '\0';
  40.   cp += 28; *cp = '\0';
  41.   cp += 21; *cp = '\0';
  42.   cp +=  6; *cp = '\0';
  43.   cp +=  8; *cp = '\0';
  44.   cp +=  4; *cp = '\0';
  45.   cp +=  2; *cp = '\0';
  46.  }
  47.  
  48.  
  49. void printrecord(RECORD record)
  50.  {
  51.   char groups[7]="SMBsmb";
  52.   int  i, linecount, expdate;
  53.   
  54.   linecount=0;
  55.  
  56.   expdate=           record.renew[0]-(int) '0';
  57.   expdate=10*expdate+record.renew[1]-(int) '0';
  58.   expdate=10*expdate+record.renew[2]-(int) '0';
  59.   expdate=10*expdate+record.renew[3]-(int) '0';
  60.  
  61.   for(i=19; ((i>1)&&(record.citystate[i-1]==' ')); i--);
  62.   record.citystate[i]='\0';
  63.  
  64.   for(i=0;((groups[i]!=record.group[0])&&(groups[i++]!='\0')););   
  65.   i++;
  66.   printf("%c!%c%cS%c",27,5,27,1);
  67.   switch (i) {
  68.     case 1:  printf("     SPACE       ");
  69.              break;
  70.     case 2:  printf("     MAST        ");
  71.              break;
  72.     case 3:  printf("     SPACE/MAST  ");
  73.              break;
  74.     default: printf("                 ");
  75.              break;
  76.   }
  77.   if (strcmp(emptyrecord.renew,record.renew)!=0) {
  78.     printf("EXP %s",record.renew);
  79.     if (expdate <currentdate) printf(" %c-%c<<You are past due!!>>%c-%c",27,1,27,0);
  80.     if (expdate==currentdate) printf(" %c-%c<<Please renew now!!>>%c-%c",27,1,27,0);
  81.   }
  82.   printf("%cT%c!%c\n",27,27,3); linecount++;
  83.   
  84.   if (strcmp(emptyrecord.title,record.title)!=0) {
  85.     printf("%s\n",record.title); linecount++;
  86.   }
  87.   if (strcmp(emptyrecord.name,record.name)  !=0) {
  88.     printf("%s\n",record.name); linecount++;
  89.   }
  90.   printf("%s\n",record.address); linecount++;
  91.   printf("%s %s\n",record.citystate,record.zip); linecount++;
  92.   while (linecount++<6) printf("\n");
  93.  }
  94.  
  95. void whatdate(void)
  96.  {
  97.   unsigned int i,day,month,year;
  98.  
  99.   i=Tgetdate();
  100.   day=i&0x1f;
  101.   month=(i>>5)&0x0f;
  102.   year=((i>>9)&0x7f)+80;
  103.   if (day>15) month++;
  104.   if (month>12) {month=1; year++;}
  105.   currentdate=year*100+month;
  106.  } 
  107.  
  108.  
  109. int main(void)
  110.  {
  111.   int  i;
  112.   char *cp;
  113.  
  114.   whatdate();
  115.   memset(emptyrecord.firstchar,' ',RECORDLEN);
  116.   memset(emptyrecord.renew,'9',4);
  117.   seteoss((char *)emptyrecord.firstchar);
  118.  
  119.   for(i=0;((cp=gets(record.firstchar))!=NULL);i++) {
  120.     seteoss(cp);
  121.     printrecord(record);
  122.   }
  123.   return (0);
  124.  }
  125.